﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;
using TMPro;
public class AlarmDataAutoItem : MonoBehaviour
{
    public TextMeshProUGUI indexText;
    public TextMeshProUGUI dataText;

    public int index 
    {
        get 
        { 
            return index; 
        } 
        set 
        {
            index = value;
            indexText.text = value.ToString("D2")+"、";
        } 
    }
    public string dataStr
    {
        get
        {
            return dataStr;
        }
        set
        {
            dataStr = value;
            dataText.text = value;
        }
    }
    private void Awake()
    {
    }
    private void Start()
    {
        AutoSctrollView.instances.AgainSortIndex += AgainSortSetIndex;
        AutoSctrollView.instances.deleatAgainSortItem += DeleatItemThis;

    }

    public void AgainSortSetIndex() 
    {
        index = transform.GetSiblingIndex();
    }

    public void DeleatItemThis(string alarmID) 
    {
        if (alarmID == this.name)
        {
            AutoSctrollView.instances.AgainSortIndex -= AgainSortSetIndex;
            DestroyImmediate(gameObject);
        }
    }
}
